package com.yd.app.service.pc.goodsWeightService;

import com.yd.app.mapper.GoodsWeightMapper;
import com.yd.app.service.common.BaseService;
import com.yd.domain.business.GoodsWeight;
import com.yd.domain.commom.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品规格Service
 * Created by sunxianhui on 2018/3/9.
 */
@Service
public class GoodsWeightService extends BaseService {
    @Autowired
    GoodsWeightMapper goodsWeightMapper;

    /**
     * 添加商品规格
     *
     * @param goodsWeight
     */
    public int addGoodsWeight(GoodsWeight goodsWeight) {
        return goodsWeightMapper.addGoodsWeight(goodsWeight);
    }

    /**
     * 修改
     *
     * @param goodsWeight
     */
    public void updateGoodsWeight(GoodsWeight goodsWeight) {
        goodsWeightMapper.updateGoodsWeight(goodsWeight);
    }

    /**
     * 根据id删除
     * @param id
     */
    public void deleteGoodsWeightById(String id) {
        goodsWeightMapper.deleteGoodsWeightById(id);
    }
    /**
     * 根据goodsId删除
     * @param goodsId
     */
    public void deleteGoodsWeightByGoodsId(String goodsId) {
        goodsWeightMapper.deleteGoodsWeightByGoodsId(goodsId);
    }
    /**
     * 根据goodsId查询商品规格列表
     * @param goodsId
     */
    public List<GoodsWeight> getGoodsWeight(String goodsId){
        List<GoodsWeight> goodsWeightList=goodsWeightMapper.getGoodsWeight(goodsId);
        return goodsWeightList;
    }
    /**
     * 根据条件分页查询
     * @param goodsId
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public PageModel getGoodsWeightList(String goodsId, int pageIndex, int pageSize) {
        PageModel pm = new PageModel();
        int startRow = getStartRow(pageIndex, pageSize);
        List<GoodsWeight> goodsWeightList = goodsWeightMapper.getGoodsWeightList(goodsId, startRow, pageSize);
        pm.setList(goodsWeightList);
        return pm;
    }
}